﻿namespace ctolua.Models
{
    /// <summary>
    /// 玩家
    /// </summary>
    public class MRole
    {
        /// <summary>
        /// 玩家对象
        /// </summary>
        public Role role { get; set; }

        public MRole(Role role)
        {
            this.role = role;
        }
        /// <summary>
        /// 玩家ID
        /// </summary>
        public int id => (int)role.api_get_role_id();
        /// <summary>
        /// 获得本地玩家
        /// </summary>
        public static MRole getOwnerRole => get_role_by_id(game_api.get_owner_role_id());
        /// <summary>
        /// 中立友善
        /// </summary>
        public static MRole getNeutralFriend => new MRole(game_api.get_role_by_int(32));
        /// <summary>
        /// 根据玩家编号获得玩家对象
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public static MRole get_role_by_id(int? id) => new MRole(game_api.get_role_by_role_id(id));



        /// 获取玩家属性名称
        ///@param res_key RoleResKey 玩家属性
        ///@return Str
        public string get_role_res_name(string res_key) => game_api.get_role_res_name(res_key);

        /// <summary>
        /// 为玩家结束游戏
        /// </summary>
        /// <param name="result ">  战斗结果   </param>
        /// <param name="show ">  显示结束面板   </param>
        /// <param name="send ">  是否上传玩家排行榜分数   False</param>
        /// <param name="score ">  排行榜分数   0</param>
        /// <param name="accumulate ">  是否累积计算分数   False</param>
        public void set_melee_result_by_role(string result, bool? show, bool? send, int? score, bool? accumulate) => game_api.set_melee_result_by_role(this.role, result, show, send, score, accumulate);

        /// 玩家是否加入游戏
        ///@return Bool
        public bool? role_in_game() => game_api.role_in_game(this.role);

        /// 设置智能施法
        ///@param value Bool 开启/关闭
        public void set_simple_cast(bool value) => game_api.set_simple_cast(this.role, value);

        /// <summary>
        /// 获取智能施法
        /// </summary>
        /// <param name="role ">  玩家   </param>
        /// <returns>是否智能施法</returns>
        public bool? get_simple_cast() => game_api.get_simple_cast(this.role);

        /// 获取客户端智能施法
        public bool? get_client_simple_cast => game_api.get_client_simple_cast(this.role);

        /// 获取玩家平台头像
        ///@return Int32
        public int? icon => game_api.get_role_platform_icon(this.role);

        /// 获取玩家平台模型
        ///@return ModelKey
        public int? model => game_api.get_role_platform_model(this.role);

        /// <summary>
        /// 打开/关闭自动施法
        /// </summary>
        /// <param name="player ">  玩家   </param>
        /// <param name="is_open ">  是否打开   </param>
        public void set_smart_cast_ability(bool is_open) => game_api.set_smart_cast_ability(this.role, is_open);

        /// <summary>
        /// 设置画风
        /// </summary>
        /// <param name="role"> 玩家 </param>
        /// <param name="post_style_type"> 画风 </param>
        /// <param name="color_r"> R </param>
        /// <param name="color_g"> R </param>
        /// <param name="color_b"> R </param>
        /// <param name="depth_scale"> 描边 </param>
        /// <param name="intensity"> 强度 </param>
        /// <returns></returns>
        public void set_post_effect(Camera post_style_type, int? color_r, int? color_g, int? color_b, double? depth_scale, double? intensity) => game_api.set_post_effect(this.role, post_style_type, color_r, color_g, color_b, depth_scale, intensity);

        /// 设置玩家的声音主单位
        ///@param unit Unit 单位
        public void set_role_micro_unit(Unit unit) => game_api.set_role_micro_unit(this.role, unit);

        /// 关闭【玩家】的附近语音聊天
        public void close_role_micro_unit() => game_api.close_role_micro_unit(this.role);

        /// 设置【玩家】的同阵营语音聊天收听开关为【布尔】
        ///@param is_open Bool 开关
        public void set_role_camp_sound_switch(bool is_open) => game_api.set_role_camp_sound_switch(this.role, is_open);

        /// 设置【玩家】的同阵营语音聊天发言开关为【布尔】
        ///@param is_open Bool 开关
        public void set_role_camp_micro_switch(bool is_open) => game_api.set_role_camp_micro_switch(this.role, is_open);

        /// 设置【玩家】的所有人语音聊天收听开关为【布尔】
        ///@param is_open Bool 开关
        public void set_role_all_sound_switch(bool is_open) => game_api.set_role_all_sound_switch(this.role, is_open);

        /// 设置【玩家】的所有人语音聊天发言开关为【布尔】
        ///@param role Role 玩家
        ///@param is_open Bool 开关
        public void set_role_all_micro_switch(bool is_open) => game_api.set_role_all_micro_switch(this.role, is_open);

        /// 修改玩家主控单位
        ///@param unit Unit 单位
        public void change_highlight_unit_of_role(Unit unit) => game_api.change_highlight_unit_of_role(this.role, unit);

        /// 设置玩家主控单位
        ///@param unit Unit 单位
        public void set_highlight_unit_of_role(Unit unit) => game_api.set_highlight_unit_of_role(this.role, unit);

        /// 获取玩家主控单位
        public void get_highlight_unit_of_role() => game_api.get_highlight_unit_of_role(this.role);

        /// 保存编辑器局内设置
        public void save_client_setting() => game_api.save_client_setting(this.role);

        /// 保存玩家设置
        public void save_game_setting() => game_api.save_game_setting(this.role);

        /// 是否让{玩家}的智能施法使用指示器
        ///@param use_skill_pointer Bool 是否使用指示器
        public void set_smart_cast_with_pointer(bool? use_skill_pointer) => game_api.set_smart_cast_with_pointer(this.role, use_skill_pointer);

        /// 设置{玩家}的普攻预览状态为{开启/关闭}
        ///@param is_open Bool 是否打开
        public void set_preview_common_atk_range(bool is_open) => game_api.set_preview_common_atk_range(this.role, is_open);

        /// 设置鼠标移动镜头模式
        ///@param value Bool 开启/关闭
        public void set_mouse_move_camera_mode(bool value) => game_api.set_mouse_move_camera_mode(this.role, value);

        /// 设置鼠标移动镜头速度
        ///@param value Float 移动速度
        public void set_mouse_move_camera_speed(double value) => game_api.set_mouse_move_camera_speed(this.role, value);

        /// 设置键盘移动镜头速度
        ///@param value Float 移动速度
        public void set_key_move_camera_speed(double value) => game_api.set_key_move_camera_speed(this.role, value);

        /// 修改玩家的地表纹理
        ///@param bool_value Bool 布尔值
        public void set_local_terrain_visible(bool bool_value) => game_api.set_local_terrain_visible(this.role, bool_value);

        /// 设置背景音乐开关
        ///@param value Bool 打开/关闭
        public void open_background_music(bool value) => game_api.open_background_music(this.role, value);

        /// 设置战斗音乐开关
        ///@param value Bool 打开/关闭
        public void open_battle_music(bool value) => game_api.open_battle_music(this.role, value);

        /// 设置背景音乐音量
        ///@param value Int32 音量
        public void set_background_music_volume(int value) => game_api.set_background_music_volume(this.role, value);

        /// 设置战斗音效音量
        ///@param value Int32 音量
        public void set_battle_music_volume(int value) => game_api.set_battle_music_volume(this.role, value);

        /// 为玩家设置滤镜效果
        ///@param value UInt64 id
        public void set_role_color_grading(int value) => game_api.set_role_color_grading(this.role, value);

        /// <summary>
        /// 设置快捷键
        /// </summary>
        /// <param name="plan ">  方案   </param>
        /// <param name="key ">  快捷键key   </param>
        /// <param name="value1 ">  键盘码1   </param>
        /// <param name="value2 ">  键盘码2   </param>
        public void set_shortcut(int? plan, string key, int? value1, int? value2) => game_api.set_shortcut(this.role, plan, key, value1, value2);

        /// 获取快捷键
        ///@param plan Int32 方案
        ///@param key Str 快捷键key
        ///@return IntList
        public dynamic get_shortcut(int? plan, string key) => game_api.get_shortcut(this.role, plan, key);

        /// 获取玩家属性Icon
        ///@param res_key RoleResKey 玩家属性
        ///@return Int32
        public int? get_role_res_icon(string res_key) => game_api.get_role_res_icon(res_key);



        /// 屏蔽全局键盘事件
        ///@param block Bool 是否屏蔽
        public void block_global_key_event(bool? block) => game_api.block_global_key_event(this.role, block);

        /// 屏蔽全局鼠标事件
        ///@param block Bool 是否屏蔽
        public void block_global_mouse_event(bool? block) => game_api.block_global_mouse_event(this.role, block);

        /// 屏蔽触发器键盘事件
        ///@param block Bool 是否屏蔽
        public void block_trigger_key_event(bool? block) => game_api.block_trigger_key_event(this.role, block);

        /// 屏蔽触发器鼠标事件
        ///@param block Bool 是否屏蔽
        public void block_trigger_mouse_event(bool? block) => game_api.block_trigger_mouse_event(this.role, block);

        /// 玩家鼠标屏幕位置X的窗口占比
        ///@return Float
        public double? get_role_ui_x_per() => game_api.get_role_ui_x_per(this.role).@float();

        /// 玩家鼠标屏幕位置Y的窗口占比
        ///@return Float
        public double? get_role_ui_y_per() => game_api.get_role_ui_y_per(this.role).@float();

        /// 玩家鼠标屏幕位置X
        ///@param role RoleID 玩家ID
        ///@return Int32
        public int? get_player_ui_pos_x() => game_api.get_player_ui_pos_x(this.role);

        /// 玩家鼠标屏幕位置Y
        ///@return Int32
        public int? get_player_ui_pos_y() => game_api.get_player_ui_pos_y(this.role);

        /// 玩家鼠标位置
        ///@return GT.point
        public int? get_player_pointing_pos() => game_api.get_player_ui_pos_y(this.role);

        /// 玩家摄像机朝向
        ///@return GT.point
        public Point get_player_camera_direction() => game_api.get_player_camera_direction(this.role);

        /// 玩家摄像机中心射线检测
        ///@return GT.point
        public Point get_camera_center_raycast() => game_api.get_camera_center_raycast(this.role);

        /// 玩家是否按下按键
        ///@param key KeyboardKey 键盘按键
        ///@return Bool
        public bool? player_key_is_pressed(int? key) => game_api.player_key_is_pressed(this.role, key);

        ///// 播放UI控件时间轴动画
        /////@param uiak UIAnimKey UI动画
        /////@param f Float 播放速度
        /////@param b Bool 是否循环
        //public void play_ui_comp_anim(int? uIAnimKey, double? seed, bool? flag) => game_api.play_ui_comp_anim(this.role, uIAnimKey, seed, flag);

        /// 停止UI控件时间轴动画
        ///@param anim_id UIAnimKey UI动画
        public void stop_ui_comp_anim(int? anim_id) => game_api.stop_ui_comp_anim(this.role, anim_id);

        /// 设置小地图替代图片
        ///@param image_id Int32 图片id
        public void change_mini_map_img(int? image_id) => game_api.change_mini_map_img(this.role, image_id);

        /// 设置小地图替代图片(图片类型)
        ///@param image_id Texture 图片
        public void change_mini_map_img_with_icon(int? image_id) => game_api.change_mini_map_img_with_icon(this.role, image_id);

        /// 设置小地图颜色显示模式
        ///@param color_type Int32 显示模式
        public void change_mini_map_color_type(int? color_type) => game_api.change_mini_map_img_with_icon(this.role, color_type);

        /// 强制踢出玩家
        ///@param reason Str 踢出理由
        public void role_force_quit(string reason) => game_api.role_force_quit(this.role, reason);

        /// 获取[玩家]的玩家昵称
        ///@return Str
        public string get_player_nick_name => game_api.get_player_nick_name(this.role);

        /// 获取[玩家]的玩家全量昵称
        ///@return Str
        public string get_player_full_nick_name => game_api.get_player_full_nick_name(this.role);

        /// 获取[玩家]的玩家aid
        ///@return Str
        public string get_player_plat_aid => game_api.get_player_plat_aid(this.role);

        /// 获取[玩家]的玩家图像
        ///@return Str
        public string get_player_icon => game_api.get_player_icon(this.role);

        /// 震动设备
        ///@param time Fixed 震动时间
        public void shake_phone(double time) => game_api.shake_phone(this.role, py.Fix32(time));

        /// 为<玩家>输入排行榜<分数>
        ///@param score Int32 战斗内排行榜分数
        public void set_role_rank_score(int score) => game_api.set_role_rank_score(this.role, score);

        /// 为玩家打开收费道具商店
        public void open_charge_item_store_for_role() => game_api.open_charge_item_store_for_role(this.role);

        /// 设置玩家的商店控件的目标商店单位
        ///@param comp_name Str 控件名
        ///@param shop_unit Unit 商店单位
        ///@param index Unit 页签索引
        public void set_shop_comp_bind_shop_unit(string comp_name, Unit shop_unit, Unit index) => game_api.set_shop_comp_bind_shop_unit(this.role, comp_name, shop_unit, index);

        /// 设置玩家的合成控件的参数并刷新
        ///@param comp_name Str 控件名
        ///@param item_id ItemID 合成目标物品id
        ///@param shop_unit Unit 商店单位
        ///@param buy_unit Unit 购买单位
        public void set_compose_comp_refresh(string comp_name, int? item_id, Unit shop_unit, Unit buy_unit) => game_api.set_compose_comp_refresh(this.role, comp_name, item_id, shop_unit, buy_unit);

        /// 打开技能指示器
        ///@param ability GT.ability 技能
        public void start_skill_pointer(Ability ability) => game_api.start_skill_pointer(this.role, ability);

        /// 关闭技能指示器
        ///@param ability Ability 技能
        public void stop_skill_pointer(Ability ability) => game_api.stop_skill_pointer(this.role, ability);

        /// 打开技能指示器
        ///@param ability Ability 技能
        public void create_preview_skill_pointer(Ability ability) => game_api.stop_skill_pointer(this.role, ability);

        /// 关闭技能指示器
        public void clear_preview_skill_pointer() => game_api.clear_preview_skill_pointer(this.role);



        /// 玩家是否拥有收费道具
        ///@param no StoreKey 收费道具key
        ///@return Bool
        public bool? role_has_store_item(int no) => game_api.role_has_store_item(this.role, no);

        /// 玩家下载存档是否回调
        ///@return Bool
        public bool? has_download_save_data_callback() => game_api.has_download_save_data_callback(this.role);

        /// 判断玩家单位类型前置条件满足需求
        ///@param unity_key UnitKey 单位类型
        ///@return Bool
        public bool? check_unit_key_precondition(int? unity_key) => game_api.check_unit_key_precondition(this.role, unity_key);

        /// 判断玩家物品类型前置条件满足需求
        ///@param item_key ItemKey 物品类型
        ///@return Bool
        public bool? check_item_key_precondition(int? item_key) => game_api.check_item_key_precondition(this.role, item_key);

        /// 判断玩家技能类型前置条件满足需求
        ///@param ability_key AbilityKey 技能类型
        ///@return Bool
        public bool? check_ability_key_precondition(int? ability_key) => game_api.check_ability_key_precondition(this.role, ability_key);


        /// <summary>
        /// 线性移动镜头(时间)
        /// </summary>
        /// <param name="role ">  玩家   </param>
        /// <param name="point ">  点   </param>
        /// <param name="duration ">  持续时间   </param>
        /// <param name="acc ">  加速度   </param>
        public void camera_linear_move_duration(Point point, Fix32 duration, int? acc = 1) => game_api.camera_linear_move_duration(this.role, point, duration, acc);


    }
}
